package ProducerConsumer;

import java.util.concurrent.BlockingQueue;

public class Consumer implements Runnable{
    private BlockingQueue<String> queue;
    public Consumer(BlockingQueue<String> queue){
        this.queue = queue;
    }


    @Override
    public void run() {
        int i = 0;
        while (i<50){
            i ++;
            try {
                System.out.println(queue.take());
                Thread.sleep(101);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
